package com.sservice.service.service.impl;

import com.sservice.common.Constants;
import com.sservice.model.dao.SearchRecordMapper;
import com.sservice.model.entity.SearchRecord;
import com.sservice.model.vo.SearchRecordVo;
import com.sservice.service.service.ISearchRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by suweiming on 2017/12/20.
 */

@Service
public class ISearchRecordServiceImpl implements ISearchRecordService {

    @Autowired
    SearchRecordMapper dao;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return dao.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(SearchRecord record) {
        return dao.insert(record);
    }

    @Override
    public int insertSelective(SearchRecord record) {
        return dao.insertSelective(record);
    }

    @Override
    public SearchRecord selectByPrimaryKey(Integer id) {
        return dao.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SearchRecord record) {
        return dao.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(SearchRecord record) {
        return dao.updateByPrimaryKey(record);
    }

    @Override
    public void log(String keyword, HttpServletRequest request,String type) {
        SearchRecord sr = new SearchRecord();
        sr.setIp(Constants.getIP(request));
        sr.setKeyword(keyword);
        sr.setType(type);// msds类型
        dao.insertSelective(sr);
    }


    @Override
    public List<SearchRecord> queryByPage(SearchRecordVo asv) {
        return dao.queryByPage(asv);
    }

    @Override
    public int queryCount(SearchRecordVo asv) {
        return dao.queryCount(asv);
    }

    ;
}
